package com.example.demo.routeStategy.strategy;

import com.example.demo.routeStategy.BeatManager;
import com.example.demo.routeStategy.ExecutorRouter;

import java.util.List;

/**
 * Created by xuxueli on 17/3/10.
 */
public class ExecutorRouteFailover extends ExecutorRouter {

    @Override
    public String route(int jobId, List<String> addressList) {
        for (String address : addressList) {
            // beat
            String beatResult = null;
            try {
                boolean isAlive = BeatManager.beat(address);
                if (isAlive){
                    return address;
                }

            } catch (Exception e) {
                logger.error(e.getMessage(), e);
            }
        }
        return null;

    }
}
